<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            background-image: url(./蔡徐坤.jpg);
            background-size: 100%;
        }

        .dl {
            width: 300px;
            height: 100px;
            position: absolute;
            left: 0;
            right: 0;
            bottom: 0;
            top: 0;
            margin: auto;
            background-color: transparent;
            border: 2px solid skyblue;
            font-size: 25px;
            color: skyblue;
            border-radius: 10px;
            
        }

        div {
            width: 500px;
            height: 300px;
            background-color: skyblue;
            position: absolute;
            left: 0;
            right: 0;
            bottom: 0;
            top: 0;
            margin: auto;
            border-radius: 20px;
            padding-top: 20px;
            display: none;
        }

        p {
            margin-top: 45px;
            margin-left: 50px;
            font-size: 18px;
            display: flex;
        }

        input {
            width: 200px;
            height: 30px;
            border-radius: 5px;
            border: 1px solid #fff;
            margin-left: 15px;
        }

        span {
            width: 60px;
            height: 30px;
            margin-left: 10px;
            align-items: center;
            color: #f9d55a;
            background-color: #fff;
            border-radius: 5px;
            font-size: 17px;
            align-content: center;
            padding-left: 10px;
        }

        .denglu,
        .qx {
            width: 100px;
            height: 30px;
            margin-top: 50px;
            margin-left: 100px;
            background-color: #fff;
            border: 1px solid #fff;
            border-radius: 5px;
        }
    </style>
</head>

<body>
    <button class="dl" onclick="dl(this)">登录</button>
    <div>
        <p>手机号: <input type="text"></p>
        <p>验证码: <input type="text"><span>9003</span></p>
        <button class="denglu" onclick="denglu()">登录</button><button class="qx" style="margin-left: 30px;">取消</button>
    </div>
</body>

</html>
<script>
    var ipt=document.querySelectorAll("input")
    var span=document.querySelector("span")
    var div=document.querySelector("div")
    var arr = '0123456789'
    var yz = ''
    function dl(a) {
        a.style.display = 'none'
        div.style.display = 'block'
    }
    function yzm(arr) {
        for (var i=0;i<4;i++){
            yz+= Math.floor(Math.random() * (arr.length))
        }
        return yz
    }
    span.innerHTML=yzm(arr)
    function denglu(){
        if(ipt[0].value==''||ipt[1].value==''){
            alert('内容或验证码为空,登录失败')
            return
        }else if(ipt[1].value!=span.innerHTML){
            alert("验证码错误")
            return
        }else{
            alert('验证码通过')
            location.href='./index.html'
            localStorage.setItem('sjh',ipt[0].value)
            ipt[0].value=''
            ipt[1].value=''
        }
    }
</script>